package d2_com.itheima.io;

import java.io.*;

/**
 * 数据流
 */
public class Test9 {
    public static void main(String[] args) {
        /**
         * 数据输出流
         */
        try (DataOutputStream dos =
                     new DataOutputStream(new FileOutputStream("oop-app6/12.txt"))) {
            dos.writeInt(87);
            dos.writeDouble(51.2);
            dos.writeBoolean(true);
            dos.writeChar('女');
            dos.writeUTF("黑马程序员"); //默认是UTF-8
        } catch (Exception e) {
            e.printStackTrace();
        }

        /**
         * 数据输入流
         */
        try (DataInputStream dos =
                     new DataInputStream(new FileInputStream("oop-app6/12.txt"))) {
            int i = dos.readInt();
            double v = dos.readDouble();
            boolean b = dos.readBoolean();
            char c = dos.readChar();
            String s = dos.readUTF();//默认是UTF-8
            System.out.println(i);
            System.out.println(v);
            System.out.println(b);
            System.out.println(c);
            System.out.println(s);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
